
import java.util.Scanner;

public class C_1_13_5 {
    public static boolean ifOK(int x) {
        for (int i = 2; i * i <= x; i++) {
            if(x % i == 0){
                return false;
            }
        }
        StringBuffer sb1 = new StringBuffer(""+x);
        
        if(sb1.toString().equals(sb1.reverse().toString())){
            return true;
        }else{
            return false;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        for (int i = 11; i <= n; i += 2) {
            if(ifOK(i)){
                sum++;
            }
        }
        System.out.print(sum);
    }
}